/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package knowledgesystem;

import cn.siox.util.math.Calculate;
import java.util.Vector;

/**
 *
 * @author Lindily
 */
public class CalculateShow {

    String str_input = "";
    double f_output;

    protected String calculateResult(String expression) {
        String temps="";
        Calculate calculator = new Calculate();
        str_input = calculator.checkExpression(expression);
        if (str_input.equals("")) {
            temps=":( 表达式出错啦!";
        } else {
            Vector<String> v_compute = calculator.getExpression(str_input);
            Vector<String> v_tmp_prefix = calculator.transformPrefix(v_compute);
            f_output = calculator.evaluatePrefix(v_tmp_prefix);
            temps = expression+" = " + f_output;
        }
        return temps;
    }
}
